import request from '@/utils/request'

/**
 * @description
 * @author Golduck
 * @date 06/05/2025
 * @export
 * @param {{
 *   flowName: string;
 *   flowType: string;
 *   remark?: string;
 *   flowInputParams?: InputParams[];
 *   flowOutputParams?: OutputParams[];
 * }} params
 * @return {*}  {ResponseResult<boolean>}
 */
export async function addDefineInfo(params) {
  return request.post(`/v1/flow/definition/add`, params);
}

export async function getDefineInfo(id) {
  return request.get(`/v1/flow/definition/info/${id}`);
}

/**
 * @description
 * @author Golduck
 * @date 06/05/2025
 * @export
 * @param {{ pageNum: number; pageSize: number; flowName?: string; flowType?: string }} params
 * @return {*}  {ResponsePageResult}
 */
export async function flowDefinePage(params) {
  return request.post('/v1/flow/definition/page', params);
}

export async function deleteFlowDefine(id) {
  return request.delete(`/v1/flow/definition/delete/${id}`);
}

/**
 * @description
 * @author Golduck
 * @date 06/05/2025
 * @export
 * @param {{
 *   id: number;
 *   flowName: string;
 *   flowType: string;
 *   remark?: string;
 *   flowInputParams?: InputParams[];
 *   flowOutputParams?: OutputParams[];
 * }} params
 * @return {*}  {ResponseResult<boolean>}
 */
export async function updateDefineInfo(params) {
  return request.put(`/v1/flow/definition/update`, params);
}

/**
 * @description
 * @author Golduck
 * @date 06/05/2025
 * @export
 * @param {{ id: number; flowContent: string; flowVariables?: FlowVariable[] }} params
 * @return {*}  {ResponseResult<boolean>}
 */
export async function saveFlowContent(params) {
  return request.put('/v1/flow/definition/save', params);
}

/**
 * @description
 * @author Golduck
 * @date 06/05/2025
 * @export
 * @param {{ flowDefinitionId: string; flowDeployVersion: string; flowVersionRemark: string }} params
 * @return {*}  {ResponsePageResult}
 */
export function deployFlowDefine(params) {
  return request.post('/v1/flow/definition/deploy', params);
}

/**
 * @description
 * @author Golduck
 * @date 06/05/2025
 * @export
 * @param {string} flowKey
 * @param {{
 *     flowData?: Record<string, any>;
 *   }} triggerData
 * @return {*}  {ResponseResult}
 */
export async function debugFlow(
  flowKey,
  triggerData
) {
  return request.post(`/v1/flow/definition/debug/${flowKey}`, triggerData);
}
